package huawei;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 空栈压数
 */
public class Q80 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> ints = Arrays.stream(sc.nextLine().split(" ")).map(String::trim).map(Integer::parseInt).collect(Collectors.toList());

        LinkedList<Integer> list = new LinkedList<>();

        for (int i = 0; i < ints.size(); i++) {
            if (!list.isEmpty()) {
                if (list.peekFirst() == ints.get(i)) {
                    list.addFirst(list.removeFirst() + ints.get(i));
                } else if (list.peekFirst() < ints.get(i) ) {
                    boolean flag = false;
                    int sum = 0;
                    for (int j = list.size() - 1; j >= 0; j--) {
                        sum += list.get(j);
                        if (sum > ints.get(i)) {
                            break;
                        } else if (sum == ints.get(i)) {
                            while (sum > 0) {
                                sum -= list.removeFirst();
                            }
                            list.addFirst(2 * ints.get(i));
                            flag = true;
                        }
                    }
                    if (!flag) {
                        list.addFirst(ints.get(i));
                    }
                } else {
                    list.addFirst(ints.get(i));
                }
            } else {
                list.addFirst(ints.get(i));
            }
        }

        System.out.println(list);
    }
}
